package com.hllxd.hism.star.basic.service.util;

import java.math.BigDecimal;

/**
 * Created by 孙强 on 2017/1/9.
 */
public class NumUtil {


    /**
     * 订单号
     **/
    public static String fixedString(String src, int limitLen, char c){
        int length = src.length();
        String dst = src;
        if(length <= limitLen){
            while(length < limitLen){
                dst = c + dst;
                length++;
            }
        }
        return dst;
    }


    /**
     * 判断一个数是否为0或null
     *
     * @param num 需要判断的数字
     * @return boolean 是否为0或null
     * @author liuxiongbo
     * @date 2020/12/19 18:56
     */
    public static boolean isNullOrZero(Number num) {
        if (null == num) {
            return true;
        }
        if (num instanceof Integer) {
            return num.equals(0);
        } else if (num instanceof Long) {
            return num.equals(0L);
        } else if (num instanceof Double) {
            return num.equals(0.0d);
        } else if (num instanceof BigDecimal) {
            return BigDecimal.ZERO.compareTo((BigDecimal) num) == 0;
        }
        return false;
    }
}
